import request from './useRequests';
import { userinfo } from '@/stores/counter';
import { ElMessage } from 'element-plus';
import getUser from './getUser';

export default function getStatus() {
  const user = userinfo();
  const { getComments } = getUser();
  async function status() {
    try {
      const res = await request({
        method: 'get',
        url: `/user/checkStatus`,
      });
      if (res.data.login == true) {
        // user.baseInfo.nickname = res.data.data.nickName
        // user.baseInfo.career = res.data.data.career
        // user.baseInfo.address = res.data.data.address
        user.baseInfo.username = res.data.data.username;
        user.baseInfo.id = res.data.data.id;
        user.baseInfo.telephone = res.data.data.telephone;
        // user.baseInfo.status = res.data.data.status;
        user.comments = await getComments();
      }
      user.signup = false;
      user.login = res.data.login;
    } catch (err: any) {
      //alert(err)
    }
  }

  return {
    status,
  };
}
